package com.alifi.crm.dal.lottery;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.alifi.crm.dal.IbatisCRUDDAO;
import com.alifi.crm.dal.object.EmployeeDO;
import com.alifi.crm.dal.object.LotteryDO;

@Repository("lotteryDAO")
public class LotteryDAOImpl extends IbatisCRUDDAO<EmployeeDO> implements LotteryDAO {

    @Override
    protected String getNamespace() {
        return "act_lottery";
    }

    @Override
    public LotteryDO selectByEmployeeNum(String employeeNum,  String gmtCreated) {
    	Map<String,String> map = new HashMap<String,String>();
        map.put("employeeNum", employeeNum);
        map.put("startGmtCreated", gmtCreated + " 00:00:00");
        map.put("endGmtCreated", gmtCreated + " 23:59:59");
        return (LotteryDO)this.getSqlMapClientTemplate().queryForObject(this.genStmt("selectByEmployeeNum"), map);
    }
    
    @Override
    public List<LotteryDO> selectByEmployeeNumList(String employeeNum,  String gmtCreated) {
    	Map<String,String> map = new HashMap<String,String>();
        map.put("employeeNum", employeeNum);
        map.put("startGmtCreated", gmtCreated + " 00:00:00");
        map.put("endGmtCreated", gmtCreated + " 23:59:59");
        return (List<LotteryDO>)this.getSqlMapClientTemplate().queryForList(this.genStmt("selectByEmployeeNumList"), map);
    }

    @Override
    public void updateLotterTime(String employeeNum,  String gmtCreated) {
    	 Map<String,String> map = new HashMap<String,String>();
         map.put("employeeNum", employeeNum);
         map.put("startGmtCreated", gmtCreated + " 00:00:00");
         map.put("endGmtCreated", gmtCreated + " 23:59:59");
        this.getSqlMapClientTemplate().update(this.genStmt("updateLotterTime"), map);
    }
    
    @Override
    public void updateLotterCurTime(String employeeNum,  String gmtCreated, String gmtModifyEd) {
    	 Map<String,String> map = new HashMap<String,String>();
         map.put("employeeNum", employeeNum);
         map.put("startGmtCreated", gmtCreated);
         map.put("endGmtCreated", gmtModifyEd);
        this.getSqlMapClientTemplate().update(this.genStmt("updateLotterCurTime"), map);
    }
    
    @Override
    public void insertLotterBatch(List<LotteryDO> batchLottery) {
    	this.getSqlMapClientTemplate().update(this.genStmt("insertLotterBatch"), batchLottery);
    }
    
}
